/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.ufrn.engcomp.pds.helloopc.modelo.dominio;

import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;

/**
 *
 * @author Felipe Rivas
 */
@Entity(name="ServidorOPC")
public class ServidorOPC implements Serializable, IEntidade {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;
    private String nome;
    private String host;
    private String serverName;
    @OneToMany(mappedBy = "servidorOPC", cascade=CascadeType.PERSIST, orphanRemoval=true)
    private List<TagOPC> tagsOPC;
    @OneToMany(mappedBy = "servidorOPC", cascade=CascadeType.PERSIST, orphanRemoval=true)
    private List<Controlador> controladores;

    @Override
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    /**
     * @return the nome
     */
    public String getNome() {
        return nome;
    }

    /**
     * @param nome the nome to set
     */
    public void setNome(String nome) {
        this.nome = nome;
    }

    /**
     * @return the url
     */
    public String getHost() {
        return host;
    }

    /**
     * @param url the url to set
     */
    public void setHost(String url) {
        this.host = url;
    }

    /**
     * @return the serverName
     */
    public String getServerName() {
        return serverName;
    }

    /**
     * @param serverName the serverName to set
     */
    public void setServerName(String serverName) {
        this.serverName = serverName;
    }

    /**
     * @return the tagsOPC
     */
    public List<TagOPC> getTagsOPC() {
        return tagsOPC;
    }

    /**
     * @param tagsOPC the tagsOPC to set
     */
    public void setTagsOPC(List<TagOPC> tagsOPC) {
        this.tagsOPC = tagsOPC;
    }

    /**
     * @return the controladores
     */
    public List<Controlador> getControladores() {
        return controladores;
    }

    /**
     * @param controladores the controladores to set
     */
    public void setControladores(List<Controlador> controladores) {
        this.controladores = controladores;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ServidorOPC)) {
            return false;
        }
        ServidorOPC other = (ServidorOPC) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        //return "br.ufrn.engcomp.pds.helloopc.dominio.ServidorOPC[id=" + id + "]";
        return this.getNome();
    }

}
